Select_All = Class.create({
    element_id_ : '',
    initialize: function(element_id) 
    {
        this.element_id_ = element_id;
        new Ajax.Request('index.php', {
            method: "get",
            parameters : {input: 'languagestring', language_string: 'select_all'},
            onSuccess: this.initializeListener.bind(this)
        });
    },
    initializeListener : function(response)
    {
        arr_response = response.responseJSON;
        if(arr_response !== null)
        {
            $(this.element_id_).wrap('div', { 'id': this.element_id_ + '_wrapper' }).insert({top: '<input type="checkbox" id="select_all_box1" class="selection" /><label for="select_all_box1" class="selection">' + arr_response['select_all'] + '</label>', bottom: '<input type="checkbox" id="select_all_box2" class="selection" /><label for="select_all_box2" class="selection">' + arr_response['select_all'] + '</label>'});
            $(this.element_id_ + '_wrapper').observe('click', this.updateSelection.bindAsEventListener(this));
        }
    },
    updateSelection : function(event)
    {
        var element = Event.findElement(event, 'input.selection');
        if (element != undefined)
        {
            is_checked = element.checked;
            $$('#' + this.element_id_ + '_wrapper input[type="checkbox"]').each(function(element){
                element.checked = is_checked; 
            }.bind(is_checked))
        }
    }
});
